package com.meichis.mcsappframework.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Window;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.swiperefreshlayout.widget.CircularProgressDrawable;

import com.meichis.mcsappframework.R;

public class LoadingDialog extends Dialog {
    public LoadingDialog(Context context) {
        super(context);
    }

    private TextView txtTips;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setBackgroundDrawable(new ColorDrawable(0));
        setContentView(R.layout.dialog_progress);
        ProgressBar progressBar = findViewById(R.id.pb_loading);
        CircularProgressDrawable drawable = new CircularProgressDrawable(getContext());
        drawable.setColorSchemeColors(Color.WHITE);
        drawable.setStyle(CircularProgressDrawable.LARGE);
        progressBar.setIndeterminateDrawable(drawable);
        txtTips = findViewById(R.id.txtTips);
    }

    public void setText(CharSequence c) {
        if (isShowing() && c != null) {
            txtTips.setText(c);
        }
    }
}